package com.atzxh.heima.algorithm;

import org.junit.Test;

/**
 * @author 小红同学
 * @date 2023-08-28-22:40
 * @description
 */
public class DynamicArrayTest {

    @Test
    public void test01() {
        DynamicArray dynamicArray = new DynamicArray();
        dynamicArray.addLast(1);
        dynamicArray.addLast(2);
        dynamicArray.addLast(3);
        dynamicArray.addLast(4);

        dynamicArray.add(2,5);

        dynamicArray.foreach(System.out::println);

        // 和上面的等价
//        dynamicArray.forEach((element)-> {
//            System.out.println(element);
//        });

        System.out.println("=============");

        for (Integer element : dynamicArray) {
            System.out.println(element);
        }

        System.out.println("=============");

        dynamicArray.stream().forEach(System.out::println);

        // 等价于
//        dynamicArray.stream().forEach(element -> {
//            System.out.println(element);
//        });

        System.out.println("================");

        int remove = dynamicArray.remove(4);
        System.out.println(remove);



    }
}
